package com.ruoyi.lclook.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lclook.domain.LcVideo;
import com.ruoyi.lclook.service.ILcVideoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品视频Controller
 * 
 * @author Choi
 * @date 2021-08-07
 */
@RestController
@RequestMapping("/lclook/video")
public class LcVideoController extends BaseController
{
    @Autowired
    private ILcVideoService lcVideoService;

    /**
     * 查询产品视频列表
     */
    @PreAuthorize("@ss.hasPermi('lclook:video:list')")
    @GetMapping("/list")
    public TableDataInfo list(LcVideo lcVideo)
    {
        startPage();
        List<LcVideo> list = lcVideoService.selectLcVideoList(lcVideo);
        return getDataTable(list);
    }

    /**
     * 导出产品视频列表
     */
    @PreAuthorize("@ss.hasPermi('lclook:video:export')")
    @Log(title = "产品视频", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LcVideo lcVideo)
    {
        List<LcVideo> list = lcVideoService.selectLcVideoList(lcVideo);
        ExcelUtil<LcVideo> util = new ExcelUtil<LcVideo>(LcVideo.class);
        return util.exportExcel(list, "产品视频数据");
    }

    /**
     * 获取产品视频详细信息
     */
    @PreAuthorize("@ss.hasPermi('lclook:video:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(lcVideoService.selectLcVideoById(id));
    }

    /**
     * 新增产品视频
     */
    @PreAuthorize("@ss.hasPermi('lclook:video:add')")
    @Log(title = "产品视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LcVideo lcVideo)
    {
        return toAjax(lcVideoService.insertLcVideo(lcVideo));
    }

    /**
     * 修改产品视频
     */
    @PreAuthorize("@ss.hasPermi('lclook:video:edit')")
    @Log(title = "产品视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LcVideo lcVideo)
    {
        return toAjax(lcVideoService.updateLcVideo(lcVideo));
    }

    /**
     * 删除产品视频
     */
    @PreAuthorize("@ss.hasPermi('lclook:video:remove')")
    @Log(title = "产品视频", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lcVideoService.deleteLcVideoByIds(ids));
    }
}
